package com.classroom.langchain.demo.config;

import com.classroom.langchain.demo.aiservice.TestChatModelListener;
import dev.langchain4j.model.chat.ChatModel;
import dev.langchain4j.model.openai.OpenAiChatModel;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.time.Duration;
import java.util.List;

@Configuration
public class LLMConfig {


//    @Bean(name = "chatModelQwen")
    public ChatModel chatModelQwen(){
        return OpenAiChatModel.builder()
                .apiKey("sk-qwen-14b-chat-v1.5-8ywz5j")
                .modelName("qwen-14b-chat")
                .baseUrl("")
                .logRequests(true)
                .logResponses(true)
                .listeners(List.of(new TestChatModelListener()))
                .maxRetries(2)
                .timeout(Duration.ofSeconds(2))
                .temperature(0.1)
                .maxTokens(1024)
                .build();
    }
}
